home *** CD-ROM | disk | FTP | other *** search
/ PC-Blue - MS DOS Public Domain Library / PC-Blue MS-DOS Public Domain Library - NYACC.iso / vol039 / wordproc.bas (.txt) < prev    next >
Encoding:
GW-BASIC  |  1987-01-11  |  5.6 KB  |  149 lines

  1. 10  REM This is a dummy line for error trapping
  2. 20  KEY OFF
  3. 30  REM Wordprocessing program called Wordproc.bas
  4. 40  REM Copyright Richard Boucher 1982
  5. 50  REM Main menu
  6. 60  CLS:WIDTH 80
  7. 70  LOCATE 11, 20: PRINT "A WORDPROCESSOR CALLED WORDPROC"
  8. 80  LOCATE 12, 25: PRINT "By Richard Boucher"
  9. 90  LOCATE 15,1: PRINT "Press any key to start"
  10. 100  GO$ = INKEY$: IF GO$ = "" THEN 100
  11. 110  CLS:PRINT "Here's what you can do ---": PRINT
  12. 120  PRINT , "W - Write a new document "
  13. 130  PRINT,  "E - Edit an old document "
  14. 140  PRINT,  "P - Print a document to the screen or to the printer "
  15. 150  PRINT,  "L - List the files on this diskette "
  16. 160  PRINT,  "Q - Or, Quit "
  17. 170  PRINT: PRINT: PRINT "What do you want to do";: INPUT DO$
  18. 180  IF DO$ = "w" OR DO$ = "W" THEN 240
  19. 190  IF DO$ = "E" OR DO$ = "e" THEN 880
  20. 200  IF DO$ = "P" OR DO$ = "p" THEN 410
  21. 210  IF DO$ = "L" OR DO$ = "l" THEN 690
  22. 220  IF DO$ = "Q" OR DO$ = "q" THEN CLS: PRINT "All gone":CLOSE: KEY ON :END
  23. 230  LOCATE 17,35:PRINT "Sorry, can't do that. Try again.": FOR I = 1 TO 600: NEXT I :CLS: GOTO 110
  24. 240  KEY (1) ON
  25. 250  ON KEY (1) GOSUB 1320  'Ends writing and goes back to main menu
  26. 260  REM   Section to write a new text
  27. 270  INPUT "What's the name of the document";TEMDOC$
  28. 280  DOC$ = TEMDOC$+".txt"
  29. 290  OPEN DOC$ AS #1 LEN = 80
  30. 300  FIELD #1, 1 AS N$,78 AS A$
  31. 310  CLS: COLOR 0,7: PRINT "     Write the text below. Press enter after each line. Press F1 to exit"
  32. 320  PRINT " Margins....................................................................../"
  33. 330  COLOR 7,0: Q = 1 :PRINT:
  34. 340  LINE INPUT TEMP$
  35. 350  LSET N$ = STR$(Q)
  36. 360  LSET A$ = TEMP$
  37. 370  PUT #1, Q
  38. 380  IF LEFT$(A$,1) = "%" THEN 400
  39. 390  Q = Q+1: GOTO 340
  40. 400  CLOSE #1: CLS: GOTO 110
  41. 410  REM  Section to print a text to the screen or the printer
  42. 420  CLS: PRINT "What's the name of the document  ("; DOC$;") ";:INPUT TEMDOC$
  43. 430  IF TEMDOC$ <>"" THEN DOC$ = TEMDOC$+".TXT"
  44. 440  PRI = 0: GOSUB 1380
  45. 450  INPUT "Do you want to print this (Y/N)"; PRI$: PRINT
  46. 460  IF PRI$ = "Y" OR PRI$ = "y" THEN PRI = 1: GOSUB 740  'Sets printer styles
  47. 470  IF DOC$ = "Envelope.TXT" OR DOC$ = "envelope.TXT" THEN DOC$ = "ENVELOPE.TXT"
  48. 480  IF PRI = 1 AND DOC$ = "ENVELOPE.TXT" THEN LPRINT CHR$(27);"8";                                           'Disables paper out for envelopes
  49. 490  OPEN DOC$ AS #1 LEN = 80
  50. 500  FIELD #1, 1 AS N$, 78 AS A$
  51. 510  IF PRI = 1 AND (EMP$ = "Y" OR EMP$ = "y") THEN LPRINT CHR$(27) "E";                       ELSE IF PRI = 1 THEN LPRINT CHR$(27) "F";
  52. 520  IF PRI = 1 AND  TIT = 1 THEN LPRINT DOC$,TIME$,DATE$: LPRINT: LPRINT
  53. 530  I = 1
  54. 540  GET #1, I
  55. 550  IF LEFT$(A$,1) = "%" THEN 650       'Checks for the end of file mark
  56. 560  IF I/20 = INT(I/20) AND PRI<>1 THEN PRINT: PRINT "Press any key to continue"                                                     ELSE 600
  57. 570  GO$ = INKEY$: IF GO$ = "" THEN 570
  58. 580  IF PRI = 1 THEN LPRINT CHR$(27);"F";
  59. 590  PRINT: PRINT:
  60. 600  PRINT A$
  61. 610  IF PRI = 1 THEN LPRINT A$ ELSE 640
  62. 620  IF PAG = 1 AND I/55 = INT(I/55) THEN LPRINT CHR$(12);                                               'Fifty five lines per page
  63. 630  IF SPA$="d" OR SPA$ = "D" THEN LPRINT          'Double spacing
  64. 640  I = I + 1: GOTO 540
  65. 650  IF PAG = 1 THEN LPRINT CHR$(12)
  66. 660  PRINT: LOCATE 24,1 : PRINT "Press any key to go back to main menu"
  67. 670  GO$ = INKEY$: IF GO$ = "" THEN 670
  68. 680  CLOSE #1: CLS: GOTO 110     'Back to main menu
  69. 690  REM  Section to list the files on this disk
  70. 700  CLS:FILES
  71. 710  LOCATE 23,10: PRINT "Press any key to return to main menu"
  72. 720  GO$ = INKEY$: IF GO$ = "" THEN 720
  73. 730  CLS: GOTO 110
  74. 740  REM  Subroutine to set the desired printer output
  75. 750  LPRINT CHR$(27);CHR$(64);
  76. 760  INPUT "Single (s) or double (d) space";SPA$
  77. 770  INPUT "Emphasized print (Default is Yes)"; EMP$
  78. 780  INPUT "Pagination (Default is Yes)"; PAG$
  79. 790  INPUT "Italics (Default is NO)"; IT$
  80. 800  INPUT "Double strike (Default is NO)";ST$
  81. 810  INPUT "Title, date and time (Defaut is No)";TIT$
  82. 820  IF PAG$ = "" OR PAG$ = "Y" OR PAG$ = "y" THEN PAG = 1 ELSE PAG = 0
  83. 830  IF TIT$ = "Y" OR TIT$ = "y" THEN TIT = 1 ELSE TIT = 0
  84. 840  IF IT$ = "y" OR IT$ = "Y" THEN LPRINT CHR$(27);"4"; ELSE LPRINT CHR$(27);"5";
  85. 850  IF ST$ = "Y" OR ST$ = "y" THEN LPRINT CHR$(27);"G"; ELSE LPRINT CHR$(27);"H";
  86. 860  IF EMP$ <> "n" OR EMP$ <> "N" THEN EMP$ = "Y"
  87. 870  CLS:RETURN
  88. 880  REM     Section to edit the text
  89. 890  CLS:PRINT "Which file do you want to edit ?   "; DOC$;: INPUT TEMDOC$
  90. 900  IF TEMDOC$<>"" THEN DOC$ = TEMDOC$+".txt":
  91. 910  GOSUB 1380
  92. 920  OPEN DOC$ AS #1 LEN = 80
  93. 930  FIELD #1, 1 AS N$, 78 AS A$
  94. 940  KEY (1) ON  'To end editing
  95. 950  KEY (5) ON  ' To delete a line
  96. 960  ON KEY(1) GOSUB 1110
  97. 970  ON KEY(5) GOSUB 1160
  98. 980  GET #1,1: IF ASC(A$) = 0 THEN GET #1,2: IF ASC(A$) = 0 THEN CLOSE: KILL DOC$: GOTO 1140
  99. 990  INPUT "Which line do you want to start with ";LIN
  100. 1000  IF LIN = 0 THEN LIN = 1
  101. 1010  CLS: COLOR 0, 7 :PRINT "Editor";,"Press ENTER to RETAIN present line.":PRINT, "Enter an F1 to END edit, or an F5 to DELETE a line": PRINT, "Don't forget to leave a ` % ' at the end of the file " :
  102. 1020  PRINT , "Go to the END of the line and hit ENTER if you make changes."
  103. 1030  PRINT:PRINT: COLOR 7,0
  104. 1040  GET #1, LIN
  105. 1050  PRINT A$;: LOCATE ,1
  106. 1060  LINE INPUT TEMP$: IF TEMP$ = "" THEN TEMP$ = A$
  107. 1070  LSET A$ = TEMP$
  108. 1080  PUT #1, LIN
  109. 1090  LIN = LIN + 1: GOTO 1040
  110. 1100  CLOSE: CLS: GOTO 110
  111. 1110  REM Subroutine called by F1 to end editing
  112. 1120  CLS: LOCATE 12,25:PRINT "Ending Edit"
  113. 1130  IF TEMP$ = "" THEN PUT #1, LIN  ELSE LSET A$ = TEMP$: PUT #1, LIN
  114. 1140  KEY (1) OFF: KEY(5) OFF :CLOSE:CLS:GOTO 110
  115. 1150  RETURN
  116. 1160  REM Subroutine to delete a line
  117. 1170  LONG = 150
  118. 1180  FOR I = LIN TO LONG-1
  119. 1190  GET #1, I+1
  120. 1200  PUT #1, I
  121. 1210  IF LEFT$(A$,1) = "%" THEN 1230
  122. 1220  NEXT I
  123. 1230  VER = CSRLIN -1: LOCATE VER,1: KEY(5) ON:
  124. 1240  RETURN 1040
  125. 1250  REM Some subroutines for errors and to end writing on F1
  126. 1260  LONG = LOF(1): LONG = LONG/128
  127. 1270  CLOSE: LOCATE 22, 1: PRINT "Press any key to go back to the main menu"
  128. 1280  KEY (1) OFF :RETURN 100
  129. 1290  CLS: LOCATE 12,20: PRINT "That's not a good name. Try again"
  130. 1300  FOR I = 1 TO 1000: NEXT I
  131. 1310  CLOSE: GOTO 410
  132. 1320  LSET N$ = STR$(Q): LSET A$ = TEMP$
  133. 1330  PUT #1, Q
  134. 1340  LSET A$ = "%": PUT #1, Q+1
  135. 1350  CLS: LOCATE 10,10: PRINT "Going back to main menu": CLOSE
  136. 1360  FOR I = 1 TO 1500: NEXT I
  137. 1370  GOTO 110
  138. 1380  REM Subroutine to identify nonexistant files
  139. 1390  ON ERROR GOTO 1430
  140. 1400  IF DOC$ = "" THEN LOCATE 10,10: COLOR 15,0: PRINT "You didn't name a file": FOR I = 1 TO 1000: NEXT I: COLOR 7,0: GOTO 110
  141. 1410  NAME DOC$ AS DOC$
  142. 1420  'This statement will cause an error
  143. 1430  X = ERR: RESUME 1440
  144. 1440  ON ERROR GOTO 0
  145. 1450  IF X = 53 THEN LOCATE 10,10: COLOR 15,0: PRINT "File not found. Going back to main menu ": DOC$ = "": FOR I = 1 TO 1500: NEXT I :COLOR 7,0: GOTO 110
  146. 1460  IF X = 58 THEN RETURN
  147. 1470  PRINT "Unexpected error" ; ERR: STOP
  148. 1480  RETURN
  149.